package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.CaseHeadExpressionContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.CaseWhenBodyThenBodyContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.CaseWhenBodyWhenBodyContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.CaseWhenElseContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.WhenExpressionContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.CaseExpressionContext;

/**
 * case 表达式语法遍历
 * @author zwd
 *
 */
public class CaseExpressionVisitor extends AbsCQLParserBaseVisitor<CaseExpressionContext>{

	private CaseExpressionContext context = null;
	
	public CaseExpressionVisitor() {
		context = new CaseExpressionContext();
	}
	
	@Override
	protected CaseExpressionContext defaultResult() {
		return context;
	}
	
	@Override
	public CaseExpressionContext visitCaseHeadExpression(@NotNull CaseHeadExpressionContext ctx) {
		CaseHeadExpressionVisitor visitor = new CaseHeadExpressionVisitor();
        context.setHead(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public CaseExpressionContext visitCaseWhenBodyWhenBody(@NotNull CaseWhenBodyWhenBodyContext ctx) {
		CaseWhenBodyWhenBodyVisitor visitor = new CaseWhenBodyWhenBodyVisitor();
        context.getWhens().add(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public CaseExpressionContext visitCaseWhenBodyThenBody(@NotNull CaseWhenBodyThenBodyContext ctx) {
		CaseWhenBodyThenBodyVisitor visitor = new CaseWhenBodyThenBodyVisitor();
        context.getThens().add(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public CaseExpressionContext visitCaseWhenElse(@NotNull CaseWhenElseContext ctx) {
		CaseWhenElseVisitor visitor = new CaseWhenElseVisitor();
        context.setCaseWhenElse(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public CaseExpressionContext visitWhenExpression(@NotNull WhenExpressionContext ctx) {
		CaseWhenElseVisitor visitor = new CaseWhenElseVisitor();
        context.setCaseWhenElse(visitor.visit(ctx));
        return context;
	}
	
	

}
